<!DOCTYPE html>
<html>

<head>
    <title>Preview Display</title>
    <meta charset="UTF-8">
    <link rel="shortcut icon" href="custom/images/favicon.ico?v=2" />
    <style>
        html,
        body {
            padding: 0px;
            margin: 0px;
        }
    </style>
    <script src='custom/libs/jquery-3.4.1.min.js'></script>
    <script src='custom/libs/echarts.js'></script>
	<script src="custom/libs/echarts.min.js"></script>
	<script src="custom/libs/china.js"></script>
	<script src="custom/libs/江西.js"></script>
    <script src='custom/configs/htconfig.js'></script>
    <script src='libs/knU3sXefAa5Q.js'></script>
    <script src='libs/ht.js'></script>
    <script src='libs/buckle.js'></script>
    <script src='libs/ht-edgetype.js'></script>
    <script src='libs/ht-ui.js'></script>
    <script src='libs/ht-vector.js'></script>
    <script src='libs/ht-animation.js'></script>
    <script>
        var dataModel = new ht.DataModel();
		// var QueryURL = "http://10.128.32.48:8090";
		var QueryURL = "https://huiqingyun.cloudiip.com";
        var tabledata2 = [];
	    var tabledata3 = [];
        function init() {
            graphView = new ht.graph.GraphView(dataModel);
            graphView.addToDOM();
			ht.Default.xhrLoad(GetQueryString('tag'), function (text) {
                var json = ht.Default.parse(text);
                if (json.title) document.title = json.title;
                dataModel.deserialize(json);
				queryData();
				realTime();
				/*1243547084
                dataModel.getDataByTag('tt2').a({
                    'ht.dataSource': tabledata2
                });
				dataModel.getDataByTag('tt3').a({
                    'ht.dataSource': tabledata3
                });
                dataModel.getDataByTag('tt2').a({
					'ht.drawRow': s1
				});
				*/
				//天刷新一次
				setInterval(function () {
                    queryData()
                }, 24*60*60*1000);
				//2秒钟刷新一次
                setInterval(function () {
                    getTableData()
                }, 10*1000);

            });
        }

        function getTableData() {
			realTime();
			tabledata2 = running(tabledata2);
			tabledata3 = running(tabledata3);
            dataModel.getDataByTag('tt2').a({
                'ht.dataSource': tabledata2
            });
			 dataModel.getDataByTag('tt3').a({
                'ht.dataSource': tabledata3
            });
            dataModel.getDataByTag('tt2').a({
                'ht.drawRow': (dataModel.getDataByTag('tt2').a("ht.drawRow") === s1 ? s2 : s1)
            });
        }
		function running(tabledata){
			var tmp = tabledata[0];
            tabledata = tabledata.splice(1, tabledata.length);
            tabledata.push(tmp);
			return tabledata;
		}
        var s1 = function (g, row, index, rect) {
            if (index % 2 === 1) {
                g.fillStyle = 'rgba(128,157,186,0.1)'
                g.fillRect(rect.x, rect.y, rect.width, rect.height);
            }
        }

        var s2 = function (g, row, index, rect) {
            if (index % 2 === 0) {
                g.fillStyle = 'rgba(128,157,186,0.1)'
                g.fillRect(rect.x, rect.y, rect.width, rect.height);
            }
        }

        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return decodeURI(r[2]);
            return null;
        }
	//查询汇总数据
	function queryData(){
		$.ajax({
			type:'get',
			url:QueryURL+"/screen/v1/summary",
			success:function(data){
				dataModel.getDataByTag('gl-1').a('ly',data.usageOverview.touristToilet);
				dataModel.getDataByTag('gl-1').a('zn',data.usageOverview.smartToilet);
				dataModel.getDataByTag('gl-1').a('cgq',data.usageOverview.sensor);
				
				dataModel.getDataByTag('jsgl').a('line1',data.constructionOverview.underConstruction);
				dataModel.getDataByTag('jsgl').a('line2',data.constructionOverview.completed);
				dataModel.getDataByTag('jsgl').a('xData',data.constructionOverview.years);
				
				dataModel.getDataByTag('csdjfb').a('ydata',data.levelDistribution);
				
				
				var arrFunds = data.fundsInvestment.funds;
				/**
				if(arrFunds.length > 1){
					dataModel.getDataByTag('zjtr').a('yAxisMax',arrFunds[0]);
					dataModel.getDataByTag('zjtr').a('yAxisMin',arrFunds[arrFunds.length-1]);
				} 
				*/
				dataModel.getDataByTag('zjtr').a('xAxisData',data.fundsInvestment.province);
				dataModel.getDataByTag('zjtr').a('dataset',arrFunds);

				dataModel.getDataByTag('cs-top').a('dataset',data.totalRanking.nums);
				dataModel.getDataByTag('cs-top').a('xAxisData',data.totalRanking.province);
				
				dataModel.getDataByTag('cx-top').a('dataset',data.smartTotalRanking.nums);
				dataModel.getDataByTag('cx-top').a('xAxisData',data.smartTotalRanking.province);
				
				dataModel.getDataByTag('cMap').a('Max',data.toiletsDistributed[0].value);
				dataModel.getDataByTag('cMap').a('data-map',data.toiletsDistributed);
				
				dataModel.getDataByTag('ssd').a('ydata',data.comfort);
				dataModel.getDataByTag('ssd').a('cText',data.comfortIndex);
				
				dataModel.getDataByTag('myd').a('ydata',data.satisfaction);
				dataModel.getDataByTag('myd').a('cText',data.satisfactionIndex);
				
				dataModel.getDataByTag('rsTOP').a('ht.dataSource',data.numberOfUsers);
				
				dataModel.getDataByTag('bjTOP').a('ht.dataSource',data.layoutRationality);
				
				dataModel.getDataByTag('cq').a('ht.dataSource',data.cleanersAttendance);
				
				dataModel.getDataByTag('sd').a('pdata',data.humidity);
				dataModel.getDataByTag('wd').a('pdata',data.temperature);
				
				tabledata2 = data.comment;
				tabledata3 = data.alarm;
				dataModel.getDataByTag('tt2').a('ht.dataSource',data.comment);
				dataModel.getDataByTag('tt3').a('ht.dataSource',data.alarm); 
			},
			error:function(xhr){
				alert("警告：" + xhr.status + " 网络异常请联系管理员");
			}	
		});
	};
	function realTime(){
		$.ajax({
			type:'get',
			url:QueryURL+"/screen/v1/pf",
			success:function(data){
				 dataModel.getDataByTag('sskl').a('sskl',data.data.total);
				 dataModel.getDataByTag('gl-2').a('nc',data.data.maleCount);
				 dataModel.getDataByTag('gl-3').a('nvc',data.data.femaleCount);
				 dataModel.getDataByTag('gl-4').a('ss',data.data.realTimeQuantity);
			},
			error:function(xhr){
				alert("警告：" + xhr.status + " 网络异常请联系管理员");
			}	
		});
	}
    </script>
</head>

<body onload='init()'>
</body>

</html>